package cate.game.play.buff.h;

import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.struct.ref.DoubleRef;

/**
 * 免疫1次致死伤害（伤害来源英雄星级不超过帝王蟹2星时生效，真实伤害和斩杀除外），只能触发1次
 */
public class 圣光BH extends BuffHandler {

	private int 次数;

	private int 星级;

	//次数=1&星级=2
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		次数 = args.getInt("次数", 0);
		星级 = args.getInt("星级", 0);
	}

	private int num;

	@Override
	public void adjustDeadlyDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		if (buff.caster.getStar() + 星级 < actor.getStar()) {
			return;
		}
		doubleRef.v = 0;
		num++;
		if (num >= 次数) {
			buff.markInvalid(action);
		}
	}
}
